import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [

    {
      path: '/button',
      meta: {
        title: '按钮'
      },
      name: 'button',
      component: () => import('../views/button.vue'),
    },
    {
      path: '/manager',
      name: 'manager',
      component: () => import('../views/manager.vue'),
      children: [
        {
          path: '/manager/data',
          meta: {
            title: '数据'
        },
          name: 'data',
          component: () => import('../views/Data.vue'),
        },
          {
            path: '/manager/home',
            name: 'home',
            meta: {
              title: '首页'
            },
            component: () => import('../views/Home.vue')
          },
        {
          path: '/manager/admin',
          meta: {
            title: '管理员'
          },
          name: 'admin',
          component: () => import('../views/Admin.vue')
        }
      ]
    }

  ],
})
router.beforeEach((to, from, next)=>{
  document.title = to.meta.title
  next()
})

export default router
